﻿using System;
using System.Web.ModelBinding;

namespace CommentPost
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) return;

            Comment comment = new Comment();
            if (!TryUpdateModel(comment, new FormValueProvider(ModelBindingExecutionContext))) return;

            CommentsCollection.GetCommentsCollection().AddResponse(comment);
            if (comment.LikedPost.HasValue && comment.LikedPost.Value)
            {
                Response.Redirect("thanksforlikingit.html");
            }
            else
            {
                Response.Redirect("ohwell.html");
            }
        }
    }
}